/*
 * @Author: CQJ
 * @Date: 2022-08-25 20:00:27
 * @LastEditors: CQJ
 * @LastEditTime: 2022-09-08 17:17:38
 * @Description:
 */
import { storage } from '@/utils/storage'
import { reactive } from 'vue'
import type { AtlasListData } from '@/types/site/atlas/atlasClass'
type Key = string
interface AtlasState {
  // 所属分类
  categ_id: string | undefined
  // 子分类关键词
  keyword: string | undefined
  site_id: string | undefined
}

// 状态管理
export const atlasState = reactive<AtlasState>({
  categ_id: undefined,
  keyword: undefined,
  site_id: undefined
})
interface StatusState {
  isEdit: boolean //是否是批量编辑
  addClassify: boolean //分类显示隐藏
  addSubClassify: boolean //子分类显示隐藏
  selectedRowKeys: Key[]
  isAddClass: boolean //是否是添加分类
  isAddSubClass: boolean //是否是添加子类
  atlasList: AtlasListData[]
}
export const statusState = reactive<StatusState>({
  isEdit: false,
  addClassify: false,
  addSubClassify: false,
  selectedRowKeys: [],
  isAddClass: false,
  isAddSubClass: false,
  atlasList: []
})
export interface ICopyList {
  id: string
  name: string
}
export const resetState = () => {
  for (const i in atlasState) {
    switch (i) {
      case 'categ_id':
        atlasState[i] = undefined
        break
      case 'keyword':
        atlasState[i] = undefined
        break
      case 'site_id':
        atlasState[i] = undefined
        break
    }
  }
}
